import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from '@vant/auto-import-resolver'
import pxtorem from 'postcss-pxtorem'
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VantResolver()]
    }),
    Components({
      resolvers: [VantResolver()]
    })
  ],
  css: {
    postcss: {
      plugins: [
        pxtorem({
          rootValue: 37.5, //手机设计稿宽度为375px的
          propList: ['*'], //属性的选择器，*表示通用
          exclude: /web/i, //忽略web下的所有文件
          selectorBlackList: ['.a-'] // 过滤掉.a- 开头的class，不进行rem转换
        })
      ]
    }
  },

  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://120.46.35.214:9999',
        changeOrigin: true
      },
      
    }
  }
})
